using UnityEngine;
using System.Collections;

public class DragPencil : MonoBehaviour 
{
    public GameObject pen;
	public Camera guiCamera;
	
	Ray ray;
	RaycastHit hit;
	
    void Update() 
	{
        ray = guiCamera.ScreenPointToRay( Input.mousePosition );
		
        if (Physics.Raycast(ray, out hit))
		{
			if ( hit.collider.tag == "DrawArea" )
				pen.transform.position = new Vector3 ( hit.point.x, hit.point.y, 0.0F );
		}
    }
}
